home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / vmcmd / vmcmd.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-18  |  6.4 KB  |  221 lines

  1. /* 
  2.  * vmcmd.c --
  3.  *
  4.  *    User interface to the Vm_Cmd system call.
  5.  *
  6.  * Copyright (C) 1986 Regents of the University of California
  7.  * All rights reserved.
  8.  */
  9.  
  10. #ifndef lint
  11. static char rcsid[] = "$Header: /sprite/src/cmds/vmcmd/RCS/vmcmd.c,v 1.9 91/03/18 13:44:52 kupfer Exp $ SPRITE (Berkeley)";
  12. #endif not lint
  13.  
  14. #include <sprite.h>
  15. #include <cfuncproto.h>
  16. #include <option.h>
  17. #include <vm.h>
  18.  
  19. /*
  20.  * Command line options.
  21.  */
  22. int    maxPageOutProcs = -1;
  23. int    pagesToCheck = -1;
  24. int    clockSleep = -1;
  25. int    canCOW = -1;
  26. int    freeWhenClean = -1;
  27. int    flushSeg = -1;
  28. int    lowPage = -1;
  29. int    highPage = -1;
  30. int    fsPenalty = -1;
  31. Boolean    resetFsMinMax = FALSE;
  32. int    numPageGroups = -1;
  33. int    alwaysRefuse = -1;
  34. int    alwaysSayYes = -1;
  35. int    corReadOnly = -1;
  36. int    useReadAhead = -1;
  37. int    prefetch = -1;
  38. int    tracesPerSecond = -1;
  39. Boolean    endTracing = FALSE;
  40. int    writeablePageout = -1;
  41. int    writeableRefPageout = -1;
  42. int    extra1 = -1;
  43. int    extra2 = 0;
  44. #ifdef spur
  45. int    flushOnRefBitClear = -1;
  46. int    setUseHardRefBit = -1;
  47. int    ownStackAndHeap = -1;
  48. int    uniprocessorFlushPage = -1;
  49. #endif
  50.  
  51. Option optionArray[] = {
  52.     {OPT_INT, "a", (Address)&alwaysRefuse, "\tSet the always refuse flag.\n"},
  53.     {OPT_INT, "A", (Address)&alwaysSayYes, "\tSet the always say yes flag.\n"},
  54.     {OPT_INT, "c", (Address)&pagesToCheck, "\tNumber of pages to check each iteration of the clock algorithm"},
  55.     {OPT_INT, "C", (Address)&canCOW, "\tSet the copy-on-write flag."},
  56.     {OPT_INT, "f", (Address)&freeWhenClean, "\tSet free when clean flag."},
  57.     {OPT_INT, "F", (Address)&fsPenalty,
  58.         "\tPenalty in seconds to make FS pay."},
  59.     {OPT_TRUE, "fsreset", (Address)&resetFsMinMax,
  60.          "\tReset the FS cache minimum and maximum."},
  61.     {OPT_INT, "x", (Address)&flushSeg, "\tSegment to flush."},
  62.     {OPT_INT, "h", (Address)&highPage, "\tHighest page to flush."},
  63.     {OPT_INT, "l", (Address)&lowPage, "\tLowest page to flush."},
  64.     {OPT_INT, "n", (Address)&numPageGroups,
  65.         "\tNumber of groups to divide available pages into.\n"},
  66.     {OPT_INT, "p", (Address)&maxPageOutProcs, "\tMaximum number of page out procs"},
  67.     {OPT_INT, "P", (Address)&prefetch, "\tSet prefetch flag"},
  68.     {OPT_INT, "r", (Address)&corReadOnly, "\tSet copy-on-ref read-only flag"},
  69.     {OPT_INT, "R", (Address)&useReadAhead, "\tSet use fs read ahead flag"},
  70.     {OPT_INT, "s", (Address)&clockSleep, "\tNumber of seconds between iterations of the clock algorithm"},
  71.     {OPT_INT, "t", (Address)&tracesPerSecond, "\tNumber of times to trace per second"},
  72.     {OPT_TRUE, "T", (Address)&endTracing, "\tEnd tracing"},
  73.     {OPT_INT, "w", (Address)&writeablePageout, "\tSet the vm writeable page out flag"},
  74.     {OPT_INT, "W", (Address)&writeableRefPageout, "\tSet the vm writeable ref page out flag"},
  75.     {OPT_INT, "e", (Address)&extra1, "\tDo extra command, with the number specified\n"},
  76.     {OPT_INT, "X", (Address)&extra2, "\tSecond argument for extra command\n"},
  77. #ifdef spur
  78.     {OPT_INT, "z", (Address)&flushOnRefBitClear, "\tSet the flush page on ref bit clear flag\n"},
  79.     {OPT_INT, "Z", (Address)&setUseHardRefBit, "\tSet the use hard ref bit flag\n"},
  80.     {OPT_INT, "o", (Address)&ownStackAndHeap, "\tSet the coherency bit in the pte of stack and heap pages\n"},
  81.     {OPT_INT, "u", (Address)&uniprocessorFlushPage, "\tSet the use uniprocessor page flush flag\n"},
  82. #endif
  83. };
  84. int numOptions = sizeof(optionArray) / sizeof(Option);
  85.  
  86. /* 
  87.  * Forward references:
  88.  */
  89.  
  90. void DoCmd _ARGS_ ((int command, int arg, int *status));
  91.  
  92.  
  93. /*
  94.  *----------------------------------------------------------------------
  95.  *
  96.  * main --
  97.  *
  98.  *    Execute the commands.
  99.  *
  100.  * Results:
  101.  *    None.
  102.  *
  103.  * Side effects:
  104.  *    Calls Vm_Cmd.
  105.  *
  106.  *----------------------------------------------------------------------
  107.  */
  108. main(argc, argv)
  109.     int argc;
  110.     char *argv[];
  111. {
  112.     int status = 0;        /* our exit status */
  113.  
  114.     (void)Opt_Parse(argc, argv, optionArray, numOptions, 0);
  115.     if (flushSeg != -1)  {
  116.     int    arr[3];
  117.     arr[0] = flushSeg;
  118.     arr[1] = lowPage;
  119.     arr[2] = highPage;
  120.     DoCmd(VM_FLUSH_SEGMENT, arr, &status);
  121.     }
  122.     if (freeWhenClean != -1) {
  123.     DoCmd(VM_SET_FREE_WHEN_CLEAN, freeWhenClean, &status);
  124.     }
  125.     if (maxPageOutProcs != -1) {
  126.     DoCmd(VM_SET_PAGEOUT_PROCS, maxPageOutProcs, &status);
  127.     }
  128.     if (pagesToCheck != -1) {
  129.     DoCmd(VM_SET_CLOCK_PAGES, pagesToCheck, &status);
  130.     }
  131.     if (clockSleep != -1) { 
  132.     DoCmd(VM_SET_CLOCK_INTERVAL, clockSleep, &status);
  133.     }
  134.     if (canCOW != -1) {
  135.     DoCmd(VM_SET_COW, canCOW, &status);
  136.     }
  137.     if (fsPenalty != -1) {
  138.     DoCmd(VM_SET_FS_PENALTY, fsPenalty, &status);
  139.     }
  140.     if (resetFsMinMax) {
  141.     DoCmd(VM_RESET_FS_STATS, 0, &status);
  142.     }
  143.     if (numPageGroups != -1) {
  144.     DoCmd(VM_SET_NUM_PAGE_GROUPS, numPageGroups, &status);
  145.     }
  146.     if (alwaysRefuse != -1) {
  147.     DoCmd(VM_SET_ALWAYS_REFUSE, alwaysRefuse, &status);
  148.     }
  149.     if (alwaysSayYes != -1) {
  150.     DoCmd(VM_SET_ALWAYS_SAY_YES, alwaysSayYes, &status);
  151.     }
  152.     if (corReadOnly != -1) {
  153.     DoCmd(VM_SET_COR_READ_ONLY, corReadOnly, &status);
  154.     }
  155.     if (useReadAhead != -1) {
  156.     DoCmd(VM_SET_USE_FS_READ_AHEAD, useReadAhead, &status);
  157.     }
  158.     if (prefetch != -1) {
  159.     DoCmd(VM_SET_PREFETCH, prefetch, &status);
  160.     }
  161.     if (tracesPerSecond != -1) {
  162.     DoCmd(VM_START_TRACING, tracesPerSecond, &status);
  163.     }
  164.     if (endTracing) {
  165.     DoCmd(VM_END_TRACING, 0, &status);
  166.     }
  167.     if (writeablePageout != -1) {
  168.     DoCmd(VM_SET_WRITEABLE_PAGEOUT, writeablePageout, &status);
  169.     }
  170.     if (writeableRefPageout != -1) {
  171.     DoCmd(VM_SET_WRITEABLE_REF_PAGEOUT, writeableRefPageout, &status);
  172.     }
  173.     if (extra1 != -1) {
  174.     DoCmd(extra1, extra2, &status);
  175.     }
  176. #ifdef spur
  177.     if (flushOnRefBitClear != -1) {
  178.     DoCmd(VM_SET_FLUSH_ON_REF_BIT_CLEAR, flushOnRefBitClear, &status);
  179.     }
  180.     if (setUseHardRefBit != -1) {
  181.     DoCmd(VM_SET_USE_HARD_REF_BIT, setUseHardRefBit, &status);
  182.     }
  183.     if (ownStackAndHeap != -1) {
  184.     DoCmd(VM_SET_COHERENCY_BIT, ownStackAndHeap, &status);
  185.     }
  186.     if (uniprocessorFlushPage != -1) {
  187.     DoCmd(VM_SET_UP_FLUSH_PAGE, uniprocessorFlushPage, &status);
  188.     }
  189. #endif
  190.  
  191.     exit(status);
  192. }
  193.  
  194.  
  195. /*
  196.  *----------------------------------------------------------------------
  197.  *
  198.  * DoCmd --
  199.  *
  200.  *    Call Vm_Cmd and check for errors.
  201.  *
  202.  * Results:
  203.  *    Sets *statusPtr to non-zero if there was an error.
  204.  *
  205.  * Side effects:
  206.  *    None.
  207.  *
  208.  *----------------------------------------------------------------------
  209.  */
  210.  
  211. void
  212. DoCmd(cmd, arg, statusPtr)
  213.     int cmd;            /* argument to Vm_Cmd */
  214.     int arg;            /* ditto */
  215.     int *statusPtr;        /* program's exit status (out) */
  216. {
  217.     if (Vm_Cmd(cmd, arg) != SUCCESS) {
  218.     *statusPtr = 1;
  219.     }
  220. }
  221.